package com.soilflow.web.controller.soilflow;


import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.dto.LandProtocolDto;
import com.soilflow.common.domain.vo.LandProtocolVo;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.info.service.LandProtocolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 转让协议Controller
 * 
 * @author relief
 * @date 2022-10-19
 */
@RestController
@RequestMapping("/land/protocol")
public class ReliefProtocolController extends BaseController
{
    @Autowired
    private LandProtocolService landProtocolService;

    /**
     * 查询转让协议列表
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol:list')")
    @GetMapping("/list")
    public TableDataInfo list(LandProtocolDto landProtocol)
    {
        startPage();
        List<LandProtocolVo> list = landProtocolService.selectLandProtocolList(landProtocol);
        return getDataTable(list);
    }



    /**
     * 查询转让协议下拉列表
     */
    @GetMapping("/all")
    public AjaxResult listAll(LandProtocolDto landProtocol)
    {
        landProtocol.setPageSize(null);
        landProtocol.setStatus("0");
        List<LandProtocolVo> list = landProtocolService.selectLandProtocolList(landProtocol);
        return AjaxResult.success(list);
    }

    /**
     * 获取转让协议详细信息
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getProtocol(@PathVariable("id") Long id)
    {
        return AjaxResult.success(landProtocolService.selectLandProtocolById(id));
    }

    /**
     * 新增转让协议
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol:add')")
    @Log(title = "转让协议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LandProtocolDto landProtocol)
    {
        return toAjax(landProtocolService.insertLandProtocol(landProtocol));
    }

    /**
     * 修改转让协议
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol:edit')")
    @Log(title = "转让协议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LandProtocolDto landProtocol)
    {
        return AjaxResult.success(landProtocolService.updateLandProtocol(landProtocol));
    }

    /**
     * 删除转让协议
     */
//    @PreAuthorize("@ss.hasPermi('land:protocol:remove')")
    @Log(title = "转让协议", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable  List<Long> ids)
    {
        return toAjax(landProtocolService.removeByIds(ids));
    }




}